const multer = require('multer');
const path = require('path');
// 配置 multer 存储
const storage = multer.diskStorage({
    destination: function (req, file, cb) {
      cb(null, 'public/images/') // 设置上传目录
    },
    filename: function (req, file, cb) {
        const randomNum = Math.floor(1000 + Math.random() * 9000); 
        cb(null, Date.now() + '-' + randomNum + path.extname(file.originalname)) // 设置文件名
    }
  });
  
  const upload = multer({ storage: storage });

module.exports = upload;